package kosta.model.friends;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import kosta.model.member.MemberVO;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class FriendsDaoImpl implements FriendsDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public List<FriendsVO> getFriendsList(String myid) throws Exception {
		System.out.println("getFriendsList DaoImpl-------- "+ myid);
		return sqlSessionTemplate.selectList("friends.getFriendsList", myid);
	}

	@Override
	public List<FriendsVO> newFriends() throws Exception {
		return sqlSessionTemplate.selectList("friends.newFriends");
	}

	@Override
	public MemberVO searchById(String search) throws Exception {
		return sqlSessionTemplate.selectOne("friends.searchById", search);
	}

	@Override
	public void joinFriend(FriendsVO fvo) throws Exception {
		sqlSessionTemplate.insert("friends.joinFriend", fvo);
	}

	@Override
	public void outFriends(String no) throws Exception {
		sqlSessionTemplate.delete("friends.outFriends", Integer.parseInt(no));
	}

	@Override
	public FriendsVO findByFriend(FriendsVO fvo) throws Exception {
		return sqlSessionTemplate.selectOne("friends.findByFriend", fvo);
	}

	@Override
	public MemberVO findByMember(String id) throws Exception {
		return sqlSessionTemplate.selectOne("member.idCheck", id);
	}

	@Override
	public void downPoint(HashMap map) throws Exception {
		sqlSessionTemplate.update("member.downPoint", map);
	}

	@Override
	public void upPoint(HashMap map) throws Exception {
		sqlSessionTemplate.update("member.upPoint", map);
	}
	
}
